package gtug.duesseldorf.server;

import gtug.duesseldorf.server.util.AssertUtil;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Pool holds references to all {@link Client}s
 * 
 */
public class ClientPool {

	/**
	 * ClientID => Client
	 */
	private static Map<String, Client> m_clients = new ConcurrentHashMap<String, Client>();

	/**
	 * get a {@link Client} by clientId
	 * 
	 * @param clientId
	 * @return
	 */
	public static Client getClient(String clientId) {
		AssertUtil.notNull(clientId, "clientId");

		return m_clients.get(clientId);
	}

	/**
	 * add a {@link Client} with key clientId
	 * 
	 * @param clientId
	 * @param client
	 */
	public static void addClient(String clientId, Client client) {
		AssertUtil.notNull(clientId, "clientId");
		AssertUtil.notNull(client, "client");

		m_clients.put(clientId, client);
	}

}
